package demo1;

public class Test {

    public static void swap(MyVal val1, MyVal val2){
        int tmp = val1.val;
        val1.val = val2.val;
        val2.val = tmp;
    }

    public static void main(String[] args) {
        MyVal myVal1 = new MyVal(10);
        MyVal myVal2 = new MyVal(20);

        System.out.println("交换前: myVal1.val = " + myVal1.val + ", myVal2.val = " + myVal2.val );
        swap(myVal1, myVal2);
        System.out.println("交换后: myVal1.val = " + myVal1.val + ", myVal2.val = " + myVal2.val );

    }
    public static void main3(String[] args) {
        Dog dog = new Dog();
        System.out.println("==========");
        // Dog dog1 = new Dog();
        Cat cat = new Cat();

    }

    public static void main2(String[] args) {
        Dog dog = new Dog("旺仔", 10, "黑色");
        dog.eat();
        System.out.println("============");
        Cat cat = new Cat("小咪", 5);
        cat.eat();
    }

    public static void main1(String[] args) {
        Dog dog = new Dog();
        dog.name = "旺财";
        dog.age = 2;
        dog.eat();
        dog.bark();

        System.out.println("=========================");

        Cat cat = new Cat();
        cat.name = "小咪";
        cat.age = 3;
        cat.eat();
        cat.mew();
    }
}
